package com.qh.yyxt.service.Impl;

import com.qh.yyxt.pojo.entity.meeting.Meeting;
import com.qh.yyxt.mapper.MeetingMapper;
import com.qh.yyxt.service.MeetingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MeetingServiceImpl implements MeetingService
{
    @Autowired
    private MeetingMapper meetingMapper;
    @Override
    public String addMeeting(String name,String site,Integer maxnum,Integer micro,Integer wireless,Integer teacup,String mes)
    {
        Meeting meeting=new Meeting();
        if(meetingMapper.findByName(name)==null)
        {
            meeting.setName(name);
            meeting.setMaxnum(maxnum);
            meeting.setMes(mes);
            meeting.setMicro(micro);
            meeting.setSite(site);
            meeting.setTeacup(teacup);
            meeting.setWireless(wireless);
        if(meetingMapper.addMeeting(meeting)==1)
            {
                return "操作成功";
            }
        }
        return "操作失败";
    }

    @Override
    public String updateMeeting(Integer id,String name,String site,Integer maxnum,Integer micro,Integer wireless,Integer teacup,String mes)
    {
        Meeting meeting=new Meeting();
        meeting.setName(name);
        meeting.setMaxnum(maxnum);
        meeting.setMes(mes);
        meeting.setMicro(micro);
        meeting.setSite(site);
        meeting.setTeacup(teacup);
        meeting.setWireless(wireless);
        meeting.setId(id);
        if(meetingMapper.updateMeeting(meeting)==1)
        {  return "操作成功";}
        else{
            return "操作失败";
        }
    }

    @Override
    public String deleteMeeting(int id)
    {

        if(meetingMapper.deleteMeeting(id)==1)
            return "操作成功";
        return "操作失败";
    }

    @Override
    public List<Meeting> findAllMeeting() {

        return meetingMapper.findAllMeeting();
    }

    @Override
    public Meeting findInfoById(Integer id) {
        if(id==null)
        {
            return null;
        }
      return meetingMapper.findInfoById(id);
    }
}
